#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int a[] = { 1,6 ,5,3,4,9};

void test()
{
	priority_queue<int,vector<int>,greater<int>> pq;
	int n = sizeof(a) / sizeof(int);
	
	for (int i = 0; i < n; i++)pq.push(a[i]);
	
	int extent = 0,count = 0;
	while (!pq.empty())
	{
		int a = pq.top();
		int b = a / 2;
		pq.pop();
		a -= extent;
		if (a <= b) count += (a - 1);
		else count += a;
			
		
	}
		
}


int main()
{
	test();

	return 0;
}